const state = {
  fields: [], // fields
  cateFields: [],
};


const actions = {
  GetFields({ commit }, data) {
    let fields = [
      {
        title: '序号',
        dataIndex: 'id',
        align: 'center',
        width: 100
      },
      // {
      //   title: '主播',
      //   dataIndex: 'user',
      //   align: 'center',
      //   scopedSlots: { customRender: 'user' },
      // },
      {
        title: '直播ID',
        dataIndex: 'qy_living_id',
        align: 'center',
      },
      {
        title: '标题',
        dataIndex: 'theme',
        align: 'center',
      },
      {
        title: '封面图',
        dataIndex: 'image',
        align: 'center',
        width: 100,
        scopedSlots: { customRender: 'image' },
      },
      {
        title: '直播状态',
        dataIndex: 'status_id',
        align: 'center',
        scopedSlots: { customRender: 'status' },
      },
      {
        title: '所属分类',
        dataIndex: 'cate_list',
        align: 'center',
        scopedSlots: { customRender: 'cate' },
      },
      {
        title: '直播时长',
        dataIndex: 'living_duration',
        align: 'center',
        // scopedSlots: { customRender: 'tag' },
      },
      {
        title: '直播开始时间',
        dataIndex: 'reserve_start',
        align: 'center',
        // scopedSlots: { customRender: 'tag' },
      },
      {
        title: '创建时间',
        dataIndex: 'create_time',
        align: 'center',
        // scopedSlots: { customRender: 'tag' },
      },
      {
        title: '操作',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' },
        align: 'center',
        width: 150,
      }
    ];
    commit('setfields', fields);
  },
  xcxGetFields({ commit }, data) {
    let fields = [
      {
        title: '序号',
        dataIndex: 'id',
        align: 'center',
        width: 100
      },
      {
        title: '直播ID',
        dataIndex: 'id',
        align: 'center',
      },
      {
        title: '标题',
        dataIndex: 'name',
        align: 'center',
      },
      {
        title: '封面图',
        dataIndex: 'cover_img',
        align: 'center',
        width: 100,
        scopedSlots: { customRender: 'image' },
      },
      {
        title: '直播状态',
        dataIndex: 'live_status',
        align: 'center',
        scopedSlots: { customRender: 'live_status' },
      },
      {
        title: '直播房间',
        dataIndex: 'roomid',
        align: 'center',
        scopedSlots: { customRender: 'cate' },
      },
      {
        title: '直播开始时间',
        dataIndex: 'start_time',
        align: 'center',
        // scopedSlots: { customRender: 'tag' },
      },
      {
        title: '直播结束时间',
        dataIndex: 'end_time',
        align: 'center',
        // scopedSlots: { customRender: 'tag' },
      },
      {
        title: '创建时间',
        dataIndex: 'create_time',
        align: 'center',
        // scopedSlots: { customRender: 'tag' },
      },
      {
        title: '操作',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' },
        align: 'center',
        width: 150,
      }
    ];
    commit('xcxLive', fields);
  },
  GetCateFields({ commit }, data) {
    let fields = [
      {
        title: '序号',
        dataIndex: 'cate_id',
        align: 'center',
      },
      {
        title: '分类名称',
        dataIndex: 'cate_name',
        align: 'center',
      },
      {
        title: '分类状态',
        dataIndex: 'status',
        align: 'center',
        scopedSlots: { customRender: 'status' },
      },
      {
        title: '排序',
        dataIndex: 'order',
        align: 'center',
        defaultSortOrder: 'descend',
        sorter: (a, b) => b.order - a.order,
        // scopedSlots: { customRender: 'tag' },
      },
      {
        title: '所属卖场',
        dataIndex: 'market_name',
        align: 'center',
      },
      {
        title: '操作',
        dataIndex: 'action',
        scopedSlots: { customRender: 'action' },
        align: 'center',
        width: 160,
      }
    ];
    commit('setCateFields', fields);
  },
};

const mutations = {
  // SetLists(state, lists) {
  //   state.List = lists;
  // },
  setfields(state, lists) {
    // console.log(state)
    state.fields = lists;
  },
  setCateFields(state, lists) {
    // console.log(state)
    state.cateFields = lists;
  },
  xcxLive(state, lists) {
    state.fields = lists;
  },
};

export default {
  namespaced: true,
  state,
  actions,
  mutations
};
